﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using EKETEAM.FrameWork;
using EKETEAM.Data;

namespace EKECMS.Phone
{
    public partial class Default : System.Web.UI.Page
    {
        public eSiteInfo siteinfo = new eSiteInfo();
        public DataRow articles, content, products, cases, pictures, videos;
        protected void Page_Load(object sender, EventArgs e)
        {
            Pub.checkPhone(); //不是手机、ipod 访问则跳转到PC版

            ((EKECMS.Master.mHome)Master).SiteInfo = siteinfo;
            eList list;
            #region 简介
            string sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=1 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            DataTable dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                content = dt.Rows[0];
                LitIntroduce.Text = eBase.DataBase.getValue("select JJ from eWeb_Columns where ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
            }
            #endregion
            #region 文章
            sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=2 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {

                articles = dt.Rows[0];
                list = new eList("eWeb_Articles");
                list.Fields.Add("ArticleID,BT");
                list.Rows = 5;
                list.Where.Add("WebCode='" + eBase.getWebCode() + "' and Show=1 and delTag=0 and SYZS=1");
                list.Where.Add("ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
                list.OrderBy.Add("ZD desc,px,ArticleID desc");

                list.Bind(RepArticles);
            }
            #endregion
            #region 产品
            sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=3 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                products = dt.Rows[0];
                list = new eList("eWeb_Products");
                list.Fields.Add("ProductID,CPMC,GGXH,XTP");
                list.Rows = 6;
                list.Where.Add("WebCode='" + eBase.getWebCode() + "' and Show=1 and delTag=0 and SYZS=1");
                list.Where.Add("ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
                list.OrderBy.Add("ZD desc,px,ProductID desc");
                list.Bind(RepProducts);
            }
            #endregion
            #region 图片
            sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=4 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                pictures = dt.Rows[0];
                list = new eList("eWeb_Pictures");
                list.Fields.Add("PictureID,bt,xtp");
                list.Rows = 3;
                list.Where.Add("WebCode='" + eBase.getWebCode() + "' and Show=1 and delTag=0 and SYZS=1");
                list.Where.Add("ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
                list.OrderBy.Add("ZD desc,px,PictureID desc");
                list.Bind(RepPics);
            }
            #endregion
            #region 案例
            sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=5 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                cases = dt.Rows[0];
                list = new eList("eWeb_Cases");
                list.Fields.Add("CaseID,BT,XTP");
                list.Rows = 3;
                list.Where.Add("WebCode='" + eBase.getWebCode() + "' and Show=1 and delTag=0 and SYZS=1");
                list.Where.Add("ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
                list.OrderBy.Add("ZD desc,px,CaseID desc");
                list.Bind(RepCases);
            }
            #endregion
            #region 视频
            sql = "select top 1 ColumnID,MC from eWeb_Columns where Type=6 and WebCode='" + eBase.getWebCode() + "' and delTag=0 and show=1 and ShowIndex=1";
            dt = eBase.DataBase.getDataTable(sql);
            if (dt.Rows.Count > 0)
            {
                videos = dt.Rows[0];
                list = new eList("eWeb_Videos");
                list.Fields.Add("VideoID,bt,xtp");
                list.Rows = 3;
                list.Where.Add("WebCode='" + eBase.getWebCode() + "' and Show=1 and delTag=0 and SYZS=1");
                list.Where.Add("ColumnID='" + dt.Rows[0]["ColumnID"].ToString() + "'");
                list.OrderBy.Add("ZD desc,px,VideoID desc");
                list.Bind(RepVideos);
            }
            #endregion
        }
    }
}